<?$this->_extends("_layouts/index_layout");?>
<?$this->_block("contents");?>
<script type="text/javascript">
function checkemail(object)
{
  $('#emailerr').remove();
  var abc = /^(\w+(\.?\w)*@[0-9a-zA-Z]+(\.[0-9a-zA-Z]+)+)?$/;
  if(!abc.test(object))
  {
    $("#span_email").after('<span id="emailerr" class="error" style="color: red">请输入有效的电子邮箱</span>')
    $('#email').focus();
  }
}
function checktel(object)
{
  $("#telerr").remove();
  var abcd = /^([\d-+]*)$/;
  if(!abcd.test(object))
  {
    $("#span_tel").after('<span id=telerr class="error" style="color: red">请输入有效的手机号码</span>')
    $('#mobile').focus();
  }
}
function checkall(){
  $('.error').remove();
  var i=0;
  if($('#username').val() == '请输入您的姓名' || $('#username').val() =='')
  {
    $('#span_username').after('<span id=usernameerr class="error" style="color: red">请输入您的姓名</span>');
    i = i+1;
  }
  if($('#email').val() == '请输入您的电子邮箱' || $('#email').val() =='')
  {
    $('#span_email').after('<span id=emailerr class="error" style="color: red">请输入您的电子邮箱</span>');
    i = i+1;
  }
  if($('#mobile').val() == '')
  {
    $('#span_tel').after('<span id=telerr class="error" style="color: red">请输入您的手机号码</span>');
    i = i+1;
  }
  if($('#content').val() == '')
  {
    $('#span_content').after('<span id=contenterr class="error" style="color: red">请输入留言内容</span>');
    i = i+1;
  }
  if($('#imgcode').val() == '')
  {
    $('#span_imgcode').after('<span id=imgerr class="error" style="color: red">请输入验证码</span>');
    i = i+1;  
  }
  var abc = /^(\w+(\.?\w)*@[0-9a-zA-Z]+(\.[0-9a-zA-Z]+)+)?$/;
  var abcd = /^([\d-+]*)$/;
  if(!abc.test($('#email').val()) && $('#email').val() != '请输入您的电子邮箱' && $('#email').val() != '')
  {
    $("#span_email").after('<span id="emailerr" class="error" style="color: red">请输入有效的电子邮箱</span>');
    i = i+1;
  }
  if(!abcd.test($('#mobile').val()) && $('#mobile').val() != '')
  {
    $("#span_tel").after('<span id=telerr class="error" style="color: red">请输入有效的手机号码</span>');
    i = i+1;
  }
  if(i > 0){return false;}
}
$(document).ready(function(){
<?php if(!empty($success)){?>
alert("您的留言已提交，请等待回复！");
window.location.href = "<?php echo url('index/guestbook');?>";
<?php }?>
})
</script>

<div class="main colorbg1 mt10"><span class="color2 ml10">您现在的位置：</span><a href="<?php echo url('index');?>">主页</a> > <a href="<?php echo url('index/guestbook');?>">在线留言</a> > 我有话说 </div>
<div class="main" style="height:500px">
<div class="border1 mt5 fright width210 ml5 height140">
  <div class="colorbg3 line30 color1">在线留言</div>
<ul class=" lb2 color4">
<li><a href="<?php echo url('index/ask');?>">我有话说</a></li>
<li><a href="<?php echo url('index/guestbook');?>">留言列表</a></li>
</ul>
</div>

<div class=" border2 color4  fleft width740 mt5">
<form action="" method="post" id="form_message">
<table cellpadding="5" cellspacing="0" width="100%">
  <br><br>
<tr align="middle"><td align="right" width="30%"><font style="color:red">*</font>你的名字：</td><td align="left" width="70%"><span id='span_username'><input value="<?php if(!empty($username)){echo $username;}else{echo '请输入您的姓名';}?>" maxlength="50" size="12" name="username" id="username" title="请输入您的姓名" onClick="if(this.value=='请输入您的姓名') this.value=''" type="text" onchange="$('#usernameerr').remove()" /></span></td></tr>
<tr align="middle"><td align="right"><font style="color:red">*</font>电子邮件：</td><td align="left"><span id='span_email'><input value="<?php if(!empty($email)){echo $email;}else{echo '请输入您的电子邮箱';}?>" maxlength="30" size="20" name="email" id="email" title="请输入您的电子邮箱" onClick="if(this.value=='请输入您的电子邮箱') this.value=''" type="text" onchange="checkemail(this.value)" /></span></td></tr>
<tr align="middle"><td align="right"><font style="color:red">*</font>手机号码：</td><td align="left"><span id='span_tel'><input maxlength="11" size="20" value="<?php echo @$mobile;?>" name="mobile" id="mobile" onchange="checktel(this.value)" /></td></tr>
<tr align="middle"><td align="right"><font style="color:red">*</font>留言内容：</td><td align="left"><span id='span_content'><textarea name="content" id='content' rows="5" cols="45" onchange="$('#contenterr').remove()" ><?php echo @$content;?></textarea></span></td></tr>
<tr align="middle"><td align="right"><font style="color:red">*</font>验证码：</td><td align="left"><span id='span_imgcode'><input id="imgcode" size="8" name="imgcode" onchange="$('#imgerr').remove()" value="<?php echo @$imgcode;?>"/></span>
      <?php if(@$code == 'F'){?>
      <span id=imgerr class="error" style="color: red">验证码错误</span>
      <?php }?></td></tr>
<tr align="middle"><td align="right">6666</td><td align="left"><img src="<?php echo url('index/imagecode');?>" id="captcha" style="cursor:pointer;"  onclick="this.src='<?php echo url('index/imagecode');?>/'+Math.random()" align="absmiddle"/>&nbsp;<a href="javascript:return false;" onClick="javascript:$('#captcha').attr('src','<?php echo url('index/imagecode');?>/'+Math.random());">看不清，换一张</a></td></tr>
<tr align="middle"><td align="right">7777</td><td align="left"><input value="提交" name="send" type="submit"  class="tj" onclick="return checkall()" /></td></tr>
</table>
</form>
</div>
<?$this->_endblock();?>
